package com.edz.dudumifi.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.edz.dudumifi.service.InitService;

/**
 * Created by EDZ on 2018/3/28.
 * 开机启动广播
 */

public class BootBroadcastReceiver extends BroadcastReceiver {

    static final String ACTION = "android.intent.action.BOOT_COMPLETED";
    private static final String TAG = "BootBroadcastReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(ACTION)) {
            Intent mainActivityIntent = new Intent(context, InitService.class);  // 要启动的服务
            mainActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startService(mainActivityIntent);
            Log.i(TAG, "在开机广播接收器中启动初始化服务");
        }
    }
}
